﻿//创建时间: 2010-12-10
//创建作者: 李 城
//功能说明: 插件管理
//最后修改: 2010-12-10

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;
using Newtonsoft.Json;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Plugin_menu : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            //base.m_strPagePermissionExtraKey = "Plugin_List";
        }
        #endregion
        
        #region 页面变量
        protected string m_strAction = "";
        protected string m_ConfigTypeKey = "Plugin";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_strAction = RequestHelper.RequestString("ac");
            if (m_strAction.IndexOf("ajax") > -1)
            {
                AjaxMethod();
            }
        }
        #endregion

        #region 页面方法
        /// <summary>
        /// ajax
        /// </summary>
        private void AjaxMethod()
        {
            JavaScriptObject result = new JavaScriptObject();
            JavaScriptObject items = new JavaScriptObject();
            string plugin_key = "";
            switch (m_strAction)
            {
                case "ajax_get_plugindata":
                    plugin_key = RequestHelper.RequestString("key");
                    if (plugin_key != "")
                    {
                        ArrayList oVarArray = SYSConfig.GetVarValue(plugin_key, m_ConfigTypeKey);
                        if (oVarArray != null && oVarArray.Count > 0)
                        {
                            for (int i = 0; i < oVarArray.Count; i++)
                            {
                                items.Add(i.ToString(), oVarArray[i]);
                            }
                            result.Add("item", items);
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "没有获取到信息"+plugin_key);
                        }
                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "参数有误");
                    }
                    break;
                default:break;
            }

            Response.Write(JavaScriptConvert.SerializeObject(result));

            base.End();
        }
        #endregion
    }
}
